package com.zz.common.utils;

import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;

public abstract class PackageUtil {
	public static int getVerCode(Context context) {
		String packageName = context.getPackageName();
		return getVerCode(context, packageName);
	}
	
	public static int getVerCode(Context context, String packageName) {
		int verCode = -1;
		try {
			verCode = context.getPackageManager().getPackageInfo(packageName, 0).versionCode;
		} catch (NameNotFoundException e) {
			e = null;
		}
		return verCode;
	}
	
	public static String getVerName(Context context) {
		String packageName = context.getPackageName();
		return getVerName(context, packageName);
	}
	
	public static String getVerName(Context context, String packageName) {
		String verName = "";
		try {
			verName = context.getPackageManager().getPackageInfo(packageName, 0).versionName;
		} catch (NameNotFoundException e) {
			e = null;
		}
		return verName;	
	}
}
